package syntax;

//import com.modeliosoft.modelio.javadesigner.annotations.objid;
//@objid ("004e0d68-be30-10d9-ac48-082e5f2773a2")
public class Message extends NamedObject {
    //@objid ("0091398a-d457-10da-ac48-082e5f2773a2")

    protected String symbol;

    private enum MessageType {

        INTERNAL, INPUT, OUTPUT;
    }
    MessageType mType;
    protected boolean input, output, internal;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        NamedObject no = (NamedObject) super.clone();
        Message message = new Message(no.getName());
        message.copyType(this);
        return message;
    }

    public Message(String name) {
        super(name);
    }

    public void copyType(Message message){
        if(message.isInput()) {
            setInput();
        }
        else if (message.isOutput()) {
            setOutput();
        }
        else if (isInternal()) {
            setInternal();
        }
        else {
            
        }    
    }
    
    public String getSymbol() {
        return symbol;
    }

    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }

    public boolean isInput() {
        return mType == MessageType.INPUT;
    }

    public void setInput() {
        mType = MessageType.INPUT;
        symbol = "?";
//        this.input = input;
//        if(input) {
//            symbol="?";
//        }
    }

    public boolean isOutput() {
        return mType == MessageType.OUTPUT;
    }

    public void setOutput() {
        mType = MessageType.OUTPUT;
        symbol = "!";
//        this.output = output;
//        if(output) {
//            symbol="!";
//        }
    }

    public boolean isInternal() {
        return mType == MessageType.INTERNAL;
    }

    public void setInternal() {
        mType = MessageType.INTERNAL;
        symbol = "--";
//        this.internal = internal;
//        if(internal) {
//            symbol="--";
//        }
    }

    @Override
    public String toString() {
        return getSymbol() + getName();
    }
}
